package qwq.zyu.TeamColor;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;

public class qwqTeamColorCommand implements CommandExecutor {

    private final Plugin plugin;
    private final qwqScheduledTeamColorTask task;

    public qwqTeamColorCommand(Plugin plugin, qwqScheduledTeamColorTask task) {
        this.task = task;
        this.plugin = plugin;
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if ( args.length != 1){
            sender.sendMessage(ChatColor.RED + "【qwq】正确用法Usage: /qwq_team_color_dye <true/false>");
            return false;
        }

        if ( args[0].equals("true") ){
            task.setEnabled(true);
            task.runTaskTimer(plugin, 0L, 1L);
            sender.sendMessage(ChatColor.GREEN + "【qwq】Team color dyeing enabled.");
            return true;
        } else if (args[0].equals("false")) {
            task.setEnabled(false);
            task.cancel();
            sender.sendMessage(ChatColor.RED + "【qwq】Team color dyeing disabled.");
            return true;
        } else {
            sender.sendMessage(ChatColor.RED + "【qwq】非法参数Invalid argument! 只有布尔值Use true/false.");
            return false;
        }
    }
}

